package com.sxm.yiwei.activitis;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.amap.api.services.core.PoiItem;
import com.sxm.yiwei.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by KuKa on 2017/6/28.
 */

public class PoiSearchAdapter extends BaseAdapter {
   private Context context;
    public List<HashMap<String,String>> slist;
   /* public PoiSearchAdapter(Context context,List<HashMap<String,String>> slist) {
        this.context=context;
        this.slist=slist;
    }*/
   public ArrayList<PoiItem> pois;
    public PoiSearchAdapter(Context context, ArrayList<PoiItem> pois) {
        this.context=context;
        this.pois=pois;
    }

    @Override
    public int getCount() {
        return pois.size();
    }

    @Override
    public Object getItem(int position) {
        return pois.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view;
        ViewHolder holder;
        if (convertView==null){
            view = View.inflate(context, R.layout.poi_item,null);
            holder = new ViewHolder();
            holder.title= (TextView) view.findViewById(R.id.poi_title);
            holder.contxet= (TextView) view.findViewById(R.id.poi_context);
            view.setTag(holder);
        }else {
            view=convertView;
            holder = (ViewHolder) view.getTag();
        }
        holder.title.setText(pois.get(position).getTitle());
        holder.contxet.setText(pois.get(position).getSnippet());
        notifyDataSetChanged();

        return view;
    }
    class ViewHolder{
        TextView title,contxet;
    }
}
